package com.shenjian.commons.utils;

/**
 * 统一相应给前端的数据
 */
public class Result {

    private Integer code;

    private String message;

    private Object data;

    public Result() {
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    //新增,修改,删除,成功时调用
    //不需要数据
    public static Result success() {
        return new Result(0, "success", null);
    }

    //查询成功时调用
    public static Result success(Object data) {
        return new Result(0, "success", data);
    }

    //失败时调用
    public static Result error() {
        return new Result(0, "error", null);
    }

//失败时调用
    public static Result error(Integer code,String message) {
        return new Result(code, message, null);
    }

    public static Result error(Object data) {
        return new Result(0, "error", data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
